<?php
require_once 'conn.php';
$id = $_GET['id'];
$result = mysqli_query($con, 'select * from user where id='.$id);
$user = mysqli_fetch_array($result, MYSQLI_ASSOC);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑会员</title>
</head>
<style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f2f2f2;
        }

        h1 {
            text-align: center;
            margin-top: 30px;
        }

        table {
            width: 80%;
            margin: 30px auto;
            border-collapse: collapse;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        th, td {
            padding: 10px;
            text-align: center;
            border: 1px solid #ccc;
        }

        th {
            background-color: #f2f2f2;
        }

        input[type="text"], input[type="password"], textarea {
            width: 100%;
            padding: 5px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }

        input[type="radio"] {
            margin-right: 5px;
        }

        input[type="submit"], a {
            padding: 10px 20px;
            background-color: #333;
            color: #fff;
            text-decoration: none;
            border-radius: 4px;
            transition: background-color 0.3s ease;
            cursor:pointer;
        }

        input[type="submit"]:hover, a:hover {
            background-color: #555;
        }
</style>
<body>
    <h1 align="center">会员管理系统</h1>
    <form action="edit.php" method="post">
        <input type="hidden" name="id" value="<?php echo $id; ?>">
        <table width="444" align="center">
            <tr>
                <td>用户名：</td>
                <td><input type="text" name="name" value="<?php echo $user['name']; ?>"></td>
            </tr>
            <tr>
                <td>密码：</td>
                <td><input type="password" name="password" value="<?php echo $user['password']; ?>"></td>
            </tr>
            <tr>
                <td>性别：</td>
                <td>
                    <input type="radio" name="sex" value="男" <?php if ($user['sex'] == '男') echo 'checked'; ?>>男
                    <input type="radio" name="sex" value="女" <?php if ($user['sex'] == '女') echo 'checked'; ?>>女
                </td>
            </tr>
            <tr>
                <td>年龄：</td>
                <td><input type="text" name="age" value="<?php echo $user['age']; ?>"></td>
            </tr>
            <tr>
                <td>爱好：</td>
                <td><input type="text" name="hobby" value="<?php echo $user['hobby']; ?>"></td>
            </tr>
            <tr>
                <td>个人简介：</td>
                <td>
                    <textarea name="detail" id="" cols="30" rows="10"><?php echo $user['detail']; ?></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" value="确认修改">
                    <a href="list.php">返回用户列表</a>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>